Skip to content

fix(ios): persist position during page list head changes#1078

Draft
alpha0010 wants to merge 1 commit intocallstack:masterfrom
alpha0010:patch-5
Draft

fix(ios): persist position during page list head changes#1078
alpha0010 wants to merge 1 commit intocallstack:masterfrom
alpha0010:patch-5

Conversation

@alpha0010
Copy link
Copy Markdown
Contributor

Summary

Dynamic changes to the page list prior to the currently visible page now maintain the same visible page on iOS (this already works on Android).

Fixes #965

Test Plan

What's required for testing (prerequisites)?

function DemoPager() {
  const allPages = [0, 1, 2, 3, 4];
  const [pages, setPages] = useState(allPages);

  const togglePage = (page: number) =>
    setPages((prev) => {
      const itemIndex = prev.indexOf(page);
      const next = [...prev];
      if (itemIndex === -1) {
        next.push(page);
        next.sort((a, b) => a - b);
      } else {
        next.splice(itemIndex, 1);
      }
      return next;
    });

  return (
    <View style={styles.container}>
      <PagerView style={styles.container}>
        {pages.map((page) => (
          <View collapsable={false} key={`x:${page}`}>
            <Text>{page}</Text>
          </View>
        ))}
      </PagerView>
      <View style={styles.container}>
        {allPages.map((page) => (
          <Button
            key={`x:${page}`}
            onPress={() => togglePage(page)}
            title={`Toggle ${page}`}
          />
        ))}
      </View>
    </View>
  );
}

const styles = StyleSheet.create({
  container: {flex: 1},
});

What are the steps to reproduce (after prerequisites)?

Use the above test screen to add/remove pages before/after the currently visible page. With this PR, iOS should now match the existing Android behavior.

Compatibility

OS Implemented
iOS
Android N/A

Checklist

  • I have tested this on a device and a simulator
  • I added the documentation in README.md
  • I updated the typed files (TS and Flow)

@alpha0010 alpha0010 marked this pull request as draft May 8, 2026 16:48
@alpha0010
Copy link
Copy Markdown
Contributor Author

Discovered a potential issue with this implementation, investigating.

@alpha0010
Copy link
Copy Markdown
Contributor Author

So, I am at a bit of a loss. After the following data transition:

Before:
A B C D E
    ^

After:
B X C Y D
    ^

Page "C" is still correctly the active page, but instead of displaying content, renders blank white. The neighboring pages still render correctly, and if I swipe away and swipe back, "C" will render again. But this error does not occur on initial load, only after using the pager some.

Any insights you might have would be greatly appreciated. I feel like I must be missing some fundamental concept, since all my logging and debugging efforts seem to say everything is working as intended.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(iOS) Dynamic pages causes page switch when adding pages at the start

1 participant